package server.controller.userController;

import server.entity.Code;
import server.entity.User;
import server.model.factory.ModelFactory;
import server.util.InfoUtils.Info;
import server.util.MyUtils;
import server.util.ResponseUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;

@WebServlet("/login")
public class LoginServlet extends HttpServlet implements Serializable {
    private static final long serialVersionUID = -3555992322762764700L;

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Code user = MyUtils.convertRequest2Bean(req, Code.class,null,null);
        System.out.println(user);
        Info info = ModelFactory.getUserModel().login(user);
        ResponseUtil.responseMessage(resp,info);
    }
}
